import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// 3. 自动引入方式： 从这里引入插件
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: [
        'vue',
        {    // 自动引入 naive ui组件
          'naive-ui': [
            'useDialog',
            'useMessage',
            'useNotification',
            'useLoadingBar'
          ]
        }
      ]
    }),
    Components({
      resolvers: [NaiveUiResolver()],
    })
  ],

  resolve: {

    // 路径别名配置
    alias: {
      // @ 别名 指向 src目录
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  lintOnSave: true,
  
});
